package com.haha.extend.HeadBar;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;

import com.Long.library.R;
import com.haha.extend.button.StateBitmapImageButton;

/**
 * Created by Administrator on 2016/6/24 0024.
 */
public class ImageInLeftAndRight extends ImageInLeftView{
    private Drawable rightImgSrcDrawable,rightImgBgDrawable;
    private StateBitmapImageButton rightImgBtn;
    public ImageInLeftAndRight(Context context) {
        this(context,null);
    }

    public ImageInLeftAndRight(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public ImageInLeftAndRight(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void getAttrs(AttributeSet attrs) {
        super.getAttrs(attrs);
        TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.ImageInLeftAndRight);
        rightImgSrcDrawable = ta.getDrawable(R.styleable.ImageInLeftAndRight_rightImgSrcDrawable);
        rightImgBgDrawable = ta.getDrawable(R.styleable.ImageInLeftAndRight_rightImgBgDrawable);
        ta.recycle();
    }

    @Override
    protected void findView() {
        super.findView();
        rightImgBtn = new StateBitmapImageButton(context);
        if (rightImgSrcDrawable != null){
            rightImgBtn.setBackgroundDrawable(rightImgSrcDrawable);
        }
        if (rightImgBgDrawable != null){
            rightImgBtn.setImageDrawable(rightImgBgDrawable);
        }
    }

    @Override
    public View getRightView() {
        return rightImgBtn;
    }
}
